;(function($,_helper,_server){
    $(function(){
        //轮播图
        var cla = "";
        $(".bookItem").each(function(index,item){
            if(index==0) cla=" active";
            else cla="";
            $(".bookBullets").append('<div class="bullet'+cla+'"></div>');
        });
        var timeOutFun = null;
        startTimeOut();
        function setBookItem(){
            $(".bookItem").each(function(){
                var $this = $(this);
                if($this.hasClass("showBook")){
                    $this.removeClass("showBook");
                }else {
                    $this.addClass("showBook");
                }
            });
            $(".bookBullets>.bullet").each(function(){
                var $this = $(this);
                if($this.hasClass("active")){
                    $this.removeClass("active");
                }else {
                    $this.addClass("active");
                }
            });
        }
        function startTimeOut(time){
            timeOutFun = setTimeout(function(){
                setBookItem();
                startTimeOut();
            },time||10000);
        }

        touch.on('.bookItem', 'swipeleft swiperight', function(ev){
            console.log("you have done", ev.type);
            var $type = ev.type;
            if($type=="swipeleft"){
                clearTimeout(timeOutFun);
                setBookItem();
                startTimeOut();
            }else if($type=="swiperight"){
                clearTimeout(timeOutFun);
                setBookItem();
                startTimeOut();
            }
        });


        //立即加入
        $(".add-btn").on("click",function(){
            $("#addForm").submit();
        });

       /* //立即转发
        $(".share-btn").on("click",function(){
            $.alert("转发成功！",function(){
                location.href="course/detail?course_id=1";
            });
        });*/
        

    });
})(Zepto,_helper,_server);


function tochapter(id){
	location.href="course/detail?course_id="+id;
}